<template>
	<view class="black">
		<image class="cover" :src="cover"
		 mode="widthFix" @longpress="operator"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cover:""
			}
		},
		methods: {
			operator(){
				var that =this;
				uni.showActionSheet({
					itemList:['下载图片','保存图片','设置图片'],
					success:function(res){
						//获取点击的下标
						console.log(res.tapIndex)
						if(res.tapIndex==0){
							uni.showLoading({
								title:"图片保存中..."
							})
							//下载
							uni.downloadFile({
								url:that.cover,
								success:function(result){
									var tempFilePath=result.tempFilePath
									console.log(tempFilePath)
									//保存文件到系统相册
									uni.saveImageToPhotosAlbum({
										filePath:tempFilePath,
										success:function(){
											uni.showToast({
												title:"保存成功",
												duration:2000
											})
										},
										complete() {
											uni.hideLoading()
										}
									})
							
								}
							})
						}
					}
				})
			}
		},
		
		onLoad(params) {
			console.log(params)
			this.cover=params.cover;
		}
	}
</script>

<style>
.black{
	background-color: #000000;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	position: fixed;
}

.cover{
	align-self: center;
}
</style>
